package objects;

import java.util.Random;

import tools.Coordinate;

import map.Item;
import map.ItemType;

public class ItemDropFactory {

	private static ItemDropFactory itemDropFactory;

	public static ItemDropFactory getInstance() {
		if (itemDropFactory == null) {
			itemDropFactory = new ItemDropFactory();
		}
		return itemDropFactory;
	}

	private ItemDropFactory() {
	}

	public Item dropNewItem(EnemyType enemyType, Coordinate coord) {

		Item itemResult = null;

		Random random = new Random();

		int dropChance = random.nextInt(100);

		if (enemyType == EnemyType.NORMAL) {

			if (dropChance < 10) {

				int rnd = random.nextInt(4);

				if (rnd == 0) {
					itemResult = new Item(coord, ItemType.HELMET);
				} else if (rnd == 1) {
					itemResult = new Item(coord, ItemType.SWORD);
				} else if (rnd == 2) {
					itemResult = new Item(coord, ItemType.SHIELD);
				} else if (rnd == 3) {
					itemResult = new Item(coord, ItemType.ARMOR);
				}

			} else if (dropChance < 60) {

				itemResult = new Item(coord, ItemType.MUSHROOM);

			}
		}

		return itemResult;

	}

}
